package cvut.fit.dpo.arithmetic.iterator;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;

import cvut.fit.dpo.arithmetic.IComponent;
import cvut.fit.dpo.arithmetic.parsing.ExpressionElement;
import cvut.fit.dpo.dfs.InOrderStrategy;

public class InOrderIterator implements Iterator<ExpressionElement>
{
	IComponent expression;
	Queue<ExpressionElement> queue;
	
	public InOrderIterator(IComponent expression){
		this.expression = expression;
		this.queue = new LinkedList<ExpressionElement>();
		this.queue = new InOrderStrategy().Search(expression);
	}
	
	@Override
	public boolean hasNext()
	{
		if(!queue.isEmpty()) return true;
		return false;
	}

	@Override
	public ExpressionElement next()
	{
		// TODO Auto-generated method stub
		return this.queue.poll();
	}

	@Override
	public void remove()
	{
		this.queue.remove();
		throw new UnsupportedOperationException("Item was removed.");
		
	}

}
